package com.platform.qujia;

public class Thread_B implements Runnable {

    private String name;
    public Thread_B(String name){
        this.name = name;
    }

    @Override
    public void run() {
       synchronized (this){
           for (int i=0; i<5; i++){
               try {
                   System.out.println(name+":"+ i);
                   Thread.sleep(1000);
//                   if(i == 3){
//                       System.out.println("B线程等于3时礼让开始...");
//                       Thread.yield();
//                       System.out.println("B线程等于3时礼让结束...");
//
//                   }
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }

           }
       }
    }
}
